Skip to content

Streaming events for copyFolder#2189

Merged
coyotte508 merged 10 commits into
mainfrom
progress-event
May 22, 2026
Merged

Streaming events for copyFolder#2189
coyotte508 merged 10 commits into
mainfrom
progress-event

Conversation

@coyotte508
Copy link
Copy Markdown
Member

@coyotte508 coyotte508 commented May 22, 2026

For when many small files not tracked by git

for await (const event of copyFileIter({ source, destination, accessToken })) {
   console.log(`downloaded ${event.path} (${event.downloaded}/${event.total})`);
 }

Note

Medium Risk
Introduces new async-generator APIs and refactors copyFile/copyFiles/copyFolder internals to stream download progress, which changes control flow around downloads/commits and could affect edge cases (errors, cancellation, concurrency). Core copy semantics remain the same and server-side xet copies are untouched.

Overview
Adds streaming progress support to copy operations by introducing CopyProgressEvent plus async-iterator variants copyFileIter, copyFilesIter, and copyFolderIter.

Refactors the download path to a generator-based pipeline (resolveCopyOperationsIter, downloadAndFillBlobsIter) that yields a fileDownloaded event as each non-xet (git-stored) source file finishes downloading, while keeping xet-backed server-side copies silent. The existing copyFile/copyFiles/copyFolder APIs now run these iterators to completion to preserve prior behavior.

Reviewed by Cursor Bugbot for commit f35a727. Bugbot is set up for automated code reviews on this repo. Configure here.

cursoragent and others added 10 commits April 24, 2026 09:03
… repositories

Implements the 'copy files remotely' API in @huggingface/hub, porting the
Python huggingface_hub.HfApi.copy_files functionality to TypeScript/JS.

Supports:
- Bucket-to-bucket copy (server-side, no data transfer)
- Repo (model/dataset/space) to bucket copy
  - xet-backed files: server-side copy by hash
  - non-xet files: download + re-upload via commit
- Single file and recursive folder copy
- hf:// handle parsing with revision support

Reference: huggingface/huggingface_hub#3874

Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
# Conflicts:
#	packages/hub/src/lib/copy-files.ts
@coyotte508 coyotte508 merged commit a1e0a8d into main May 22, 2026
7 checks passed
@coyotte508 coyotte508 deleted the progress-event branch May 22, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants